from django.views.generic import ListView, DetailView, CreateView, \
                                 DeleteView, UpdateView, \
                                 ArchiveIndexView, DateDetailView, \
                                 DayArchiveView, MonthArchiveView, \
                                 TodayArchiveView, WeekArchiveView, \
                                 YearArchiveView


from weather.models import Forecasting


class ForecastingView(object):
    model = Forecasting

    def get_template_names(self):
        """Nest templates within forecasting directory."""
        tpl = super(ForecastingView, self).get_template_names()[0]
        app = self.model._meta.app_label
        mdl = 'forecasting'
        self.template_name = tpl.replace(app, '{0}/{1}'.format(app, mdl))
        return [self.template_name]


class ForecastingDateView(ForecastingView):
    date_field = 'date'
    month_format = '%m'


class ForecastingBaseListView(ForecastingView):
    paginate_by = 10


class ForecastingArchiveIndexView(
    ForecastingDateView, ForecastingBaseListView, ArchiveIndexView):
    pass


class ForecastingCreateView(ForecastingView, CreateView):
    pass


class ForecastingDateDetailView(ForecastingDateView, DateDetailView):
    pass


class ForecastingDayArchiveView(
    ForecastingDateView, ForecastingBaseListView, DayArchiveView):
    pass


class ForecastingDeleteView(ForecastingView, DeleteView):

    def get_success_url(self):
        from django.core.urlresolvers import reverse
        return reverse('weather_forecasting_list')


class ForecastingDetailView(ForecastingView, DetailView):
    pass


class ForecastingListView(ForecastingBaseListView, ListView):
    pass


class ForecastingMonthArchiveView(
    ForecastingDateView, ForecastingBaseListView, MonthArchiveView):
    pass


class ForecastingTodayArchiveView(
    ForecastingDateView, ForecastingBaseListView, TodayArchiveView):
    pass


class ForecastingUpdateView(ForecastingView, UpdateView):
    pass


class ForecastingWeekArchiveView(
    ForecastingDateView, ForecastingBaseListView, WeekArchiveView):
    pass


class ForecastingYearArchiveView(
    ForecastingDateView, ForecastingBaseListView, YearArchiveView):
    make_object_list = True



